package org.lisa.crm.controller.marketing;

import org.lisa.crm.common.util.Result;
import org.lisa.crm.framework.context.BaseController;
import org.lisa.crm.model.SaleChance;
import org.lisa.crm.service.MarketingService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * Created by admin on 2018/1/7.
 */
@Controller
@RequestMapping("/marketing")
public class MarketingController extends BaseController{

    @Autowired
    private MarketingService marketingService;

    @RequestMapping("/{page}/index.html")
    public String index(@PathVariable("page") int  page){
        String res = "";
        switch (page){
            case 1:
                res = "sale_chance";
                break;
            case 2:
                res = "cus_dev_plan";
                break;
            default:
                res = "500";
        }
        return res;
    }

    @RequestMapping("/querySaleChancesByParams")
    @ResponseBody
    public Map<String,Object> querySaleChancesByParams(SaleChance salechance){
        return marketingService.querySaleChancesByParams(salechance);
    }


    /*
    /marketing/insert
     */
    @RequestMapping("/insert")
    @ResponseBody
    public Result insertSaleschance(SaleChance saleChance){
        return marketingService.insertSaleschance(saleChance);
    }


    /*
    /marketing/update";
     */
    @RequestMapping("/update")
    @ResponseBody
    public Result updateSaleschance(SaleChance saleChance){
        return marketingService.updateSaleschance(saleChance);
    }


    /*
    "/marketing/delete"
     */
    @RequestMapping("/delete")
    @ResponseBody
    public Result deleteSaleschance(int ids){

        return marketingService.deleteSaleschance(ids);
    }


    //updateSaleChanceDevResult
    /*
    开发成功 2 终止开发  3
     */
    @RequestMapping("/updateSaleChanceDevResult")
    @ResponseBody
    /*
    devResult对应请求过来的url中的key 会将这个值付给形式参数devResult

     */
    public Result updateSaleChanceDevResult(@RequestParam ("devResult")Integer devResult ,@RequestParam ("sid") Integer sid){

        return marketingService.updateSaleChanceDevResult(devResult,sid);

    }
}
